package com.ruoyi.project.remake.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.remake.domain.PayMent;
import com.ruoyi.project.remake.service.IPayMentService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 收款模块Controller
 * 
 * @author 孙山伟
 * @date 2023-03-28
 */
@RestController
@RequestMapping("/remake/ment")
public class PayMentController extends BaseController
{
    @Autowired
    private IPayMentService payMentService;

    /**
     * 查询收款模块列表
     */
    @PreAuthorize("@ss.hasPermi('remake:ment:list')")
    @GetMapping("/list")
    public TableDataInfo list(PayMent payMent)
    {
        startPage();
        List<PayMent> list = payMentService.selectPayMentList(payMent);
        return getDataTable(list);
    }

    /**
     * 导出收款模块列表
     */
    @PreAuthorize("@ss.hasPermi('remake:ment:export')")
    @Log(title = "收款模块", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PayMent payMent)
    {
        List<PayMent> list = payMentService.selectPayMentList(payMent);
        ExcelUtil<PayMent> util = new ExcelUtil<PayMent>(PayMent.class);
        return util.exportExcel(list, "ment");
    }

    /**
     * 获取收款模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('remake:ment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(payMentService.selectPayMentById(id));
    }

    /**
     * 新增收款模块
     */
    @PreAuthorize("@ss.hasPermi('remake:ment:add')")
    @Log(title = "收款模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PayMent payMent)
    {
        return toAjax(payMentService.insertPayMent(payMent));
    }

    /**
     * 修改收款模块
     */
    @PreAuthorize("@ss.hasPermi('remake:ment:edit')")
    @Log(title = "收款模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PayMent payMent)
    {
        return toAjax(payMentService.updatePayMent(payMent));
    }

    /**
     * 删除收款模块
     */
    @PreAuthorize("@ss.hasPermi('remake:ment:remove')")
    @Log(title = "收款模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(payMentService.deletePayMentByIds(ids));
    }
}
